package headfirst.decorater;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;

public class RawSearchReuslt implements SearchResult
{
	ArrayList< HashMap<String, String> > reslist=null;
	
	public ArrayList< HashMap<String, String> > getSortedList()
	{
		System.out.println("in RawSearchReuslt, call getSortedList");
		return this.reslist;
	}
	
	public boolean dosearch(String[] conditions)
	{
		System.out.println("in RawSearchReuslt, call dosearch");
		HashMap<String, String> tmpinfo;
		this.reslist = new ArrayList< HashMap<String, String> >();
		
		Date nowd = new Date();
		long nowts = nowd.getTime();
		for(int k=0; k<5; ++k)
		{
			tmpinfo = new HashMap<String, String>();
			tmpinfo.put("id", 		""+k);
			tmpinfo.put("city", 	""+(0==k%2 ? "2595" : "90"));
			tmpinfo.put("catid", 	""+(10+k));
			tmpinfo.put("title", 	"test title");
			tmpinfo.put("digest", 	"test digest");
			tmpinfo.put("kbrank", 	""+(100-k*10));
			tmpinfo.put("ctime", 	""+(nowts+k*10-86400));
			tmpinfo.put("mtime", 	""+(nowts-k*10));
			this.reslist.add(tmpinfo);
		}
		return true;
	}
}
